const express = require("express")
const router = express.Router()

// 引入控制层
const User = require("../controllers/users")

// 引入中间件
const checkPermission = require('../middleware/checkPermission');
const auth = require('../middleware/auth');

router.post('/login', User.login)
router.get('/findByPk', auth, User.findByPk)
router.get('/findByUsername', auth, User.findByUsername)
router.post('/add', auth, checkPermission('user_add'), User.create)

router.get('/userPermiss', auth, User.userPermiss)
router.get("/check", User.checkToken)

router.get('/logout', User.logout)
router.get("/userlist", auth, checkPermission('user_list'), User.list)


// 4. 用户的删除-真删除
router.get("/delete_t", auth, checkPermission('user_delete'), User.delete_t)
// 7. 用户的修改-设置数据
router.post("/edit_set", auth, checkPermission('user_edit'), User.edit_set_c)

module.exports = router